﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Skyhook.Core;

namespace Skyhook.Isometry
{
    internal class WorldTile
    {
        List<WorldObject> Objects = null;
        
        public WorldTile()
        {
            Objects = new List<WorldObject>();
        }

        public virtual void AddObject(WorldObject worldobject)
        {
            if (worldobject == null)
            {
                return;
            }

            Objects.Add(worldobject);
        }

        public virtual void AddOrReplaceEqualObject(WorldObject worldobject)
        {
            if (worldobject == null)
            {
                return;
            }

            Objects.Remove(worldobject);
            Objects.Add(worldobject);
        }

        public virtual bool RemoveObject(WorldObject worldobject)
        {
            return Objects.Remove(worldobject);
        }

        public virtual WorldObject GetObject(int index)
        {
            if (index < 0 || index >= Objects.Count)
            {
                return null;
            }
            return Objects[index];
        }

        public virtual int ObjectsCount
        {
            get
            {
                return Objects.Count;
            }
        }
    }
}
